<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <!--{include file='comm/comm_cal.tpl'}-->
    <title>顺丰出仓单导入</title>
</head>
<body>

<div class="container">
    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form id="sms_form" class="form-inline" onsubmit="return false;">
                        <input type="button" value="顺丰出仓单导入" class="btn btn-primary" onclick="customerSms.import();" /> 文件格式，第一列为订单编号，第二列为顺丰运单号。<font color="red">每次最多可导入2000条数据。</font>
                    </form>
                </div>
            </div>
        </div>

</div>
<!--导入 开始-->
<div id="import" style="display: none;">
    <form id="upload_form" name="upload_form" method="post" enctype="multipart/form-data" action="/quanliadmin/app/bill/sfImporting.pscript?operFlg=3" target="hide_frame">
        <span style="display: inline-block;">
            <input size="130" type="file" id="search_file" name="search_file" style="width:300px">
        </span>
        <input type="button" name="into_sub" id="into_sub" class="btn btn-primary" value="导入">
        <br/>
        <div id="importMsg" style="line-height: 30px;"></div>
        <iframe id="hide_frame" name="hide_frame" style="display: none;"></iframe>
    </form>
</div>
<!--导入 结束-->
<script type="text/javascript">

    var customerSms = {

        //顺丰出仓单导入
        import:function(){
            $("#upload_form").attr("action","/quanliadmin/app/bill/sfImporting.pscript?operFlg=3");
            E.popup.open({
                id: 'import',
                title: '顺丰出仓单导入',
                css: 'width: 500px;'
            });
        },
        //信息提示
        importMsg : function (msg, flg){
            if(flg == 0){
                $("#importMsg").css("color","red");
            }else{
                $("#importMsg").css("color","green");
                //更新 input file
                var input_html = $("#search_file").clone();
                $("#search_file").remove();
                $("#searchForm").prepend(input_html);
                msg = "导入成功";
            }
            $("#importMsg").html(msg);
        }

    };

    //导入执行
    $(document).on('click','#into_sub',function(){
        var filename = $('#search_file').val();
        if(filename == ''){
            customerSms.importMsg('请选择上传文件',0);
            return false;
        }

        var basename = filename.split(".");
        if(basename[basename.length-1].toLowerCase() != 'xlsx'){
            customerSms.importMsg('文件类型错误，请选择xlsx文件',0);
            return false;
        }

        $("#importMsg").css("color","black");
        $("#importMsg").text("正在导入，请稍后...");

        $("#upload_form").submit();

    });
</script>
</body>
</html>